package com.skyworth.web.admin.user.domain;

import java.util.ArrayList;


public enum UserKind {
    WAITER,
    CASHIER,
    BOSS,
    ADMIN
    ;

    public String kindName() {
        String name = "服务员";
        switch (this) {
            case WAITER: {
                name = "服务员";
                break;
            }
            case CASHIER: {
                name = "收银员";
                break;
            }
            case BOSS: {
                name = "店长";
                break;
            }
            case ADMIN: {
                name = "管理员";
                break;
            }
            default: {
                name = "服务员";
            }
        }
        return name;
    }


    public boolean equalToCodeStr(String codeStr) {
        int code = Integer.parseInt(codeStr);
        return code == this.ordinal();
    }

    static public ArrayList<ArrayList<String>> options() {
        ArrayList<ArrayList<String>> arr = new ArrayList<>();

        for (int i = 0; i < UserKind.values().length; i++) {
            UserKind uk = UserKind.values()[i];
            if(uk == UserKind.ADMIN) {
                continue;
            }
            ArrayList<String> _arr = new ArrayList<>();
            _arr.add("" + uk.ordinal());
            _arr.add(UserKind.values()[i].kindName());
            arr.add(_arr);
        }
        return arr;
    }

    static public UserKind initWithCode(int code) {
        if (UserKind.BOSS.ordinal() == code) {
            return UserKind.BOSS;
        } else if (UserKind.WAITER.ordinal() == code) {
            return UserKind.WAITER;
        } else if (UserKind.CASHIER.ordinal() == code) {
            return UserKind.CASHIER;
        } else  {
            return UserKind.ADMIN;
        }
    }
}
